Inside Macintosh: QuickTime

Previous | Chapter Top | Chapter Contents | Next

Progress Functions

Some Movie Toolbox functions can take a long time to execute. For example, creating a movie file that contains all of its data may be quite an involved process for a movie that has many large media structures. During these operations, your application should give the user some indication of the progress of the task. The Movie Toolbox allows you to monitor its progress on long operations with a progress function.

The Movie Toolbox calls your progress function at regular intervals during long operations. The Movie Toolbox determines whether to call your function based on the duration of the operation--your function will not be called unnecessarily. When it calls your function, the Movie Toolbox provides information about the operation that is underway and its relative completion. You can use this information to display an informational dialog box to the user.

You assign a progress function to a movie by calling the SetMovieProgressProc function (described on SetMovieProgressProc ). You should assign your progress function when you open the movie; the Movie Toolbox will call your function when it is appropriate to do so. One progress function may support more than one movie. When the Movie Toolbox calls your function, it provides you with the movie identifier so that you can discriminate between various movies.

MyProgressProc

Your progress function should support the following interface:

pascal OSErr MyProgressProc (Movie theMovie, short message,
                                         short whatOperation,
                                         Fixed percentDone, long refcon);
theMovie
Specifies the movie for this operation. The Movie Toolbox sets this parameter to identify the appropriate movie.
message
Indicates why the Movie Toolbox called your function. The following values are valid:
movieProgressOpen
Indicates the start of a long operation. This is always the first message sent to your function. Your function can use this message to trigger the display of your progress window.
movieProgressUpdatePercent
Passes completion information to your function. The Movie Toolbox repeatedly sends this message to your function. The percentDone parameter indicates the relative completion of the operation. You can use this value to update your progress window.
movieProgressClose
Indicates the end of a long operation. This is always the last message sent to your function. Your function can use this message as an indication to remove its progress window.
whatOperation
Indicates the long operation that is currently underway. The following values are valid:
progressOpFlatten
Your application has called the FlattenMovie or FlattenMovieData function (described on FlattenMovie and FlattenMovieData , respectively).
progressOpInsertTrackSegment
Your application has called the InsertTrackSegment function (described on InsertTrackSegment ). The Movie Toolbox calls the progress function that is assigned to the movie that contains the destination track.
progressOpInsertMovieSegment
Your application has called the InsertMovieSegment function (described on InsertMovieSegment ). The Movie Toolbox calls the progress function that is assigned to the destination movie.
progressOpPaste
Your application has called the PasteMovieSelection function (described on PasteMovieSelection ). The Movie Toolbox calls the progress function that is assigned to the destination movie.
progressOpAddMovieSelection
Your application has called the AddMovieSelection function (described on AddMovieSelection ). The Movie Toolbox calls the progress function that is assigned to the destination movie. The Movie Toolbox calls the progress function that is assigned to the destination movie.
progressOpCopy
Your application has called the CopyMovieSelection function (described on CopyMovieSelection ). The Movie Toolbox calls the progress function that is assigned to the destination movie.
progressOpCut
Your application has called the CutMovieSelection function (described on CutMovieSelection ). The Movie Toolbox calls the progress function that is assigned to the destination movie.
progressOpLoadMovieIntoRam
Your application has called the LoadMovieIntoRam function (described on LoadMovieIntoRam ). The Movie Toolbox calls the progress function that is assigned to the destination movie.
progressOpLoadTrackIntoRam
Your application has called the LoadTrackIntoRam function (described on LoadTrackIntoRam ). The Movie Toolbox calls the progress function that is assigned to the destination track.
progressOpLoadMediaIntoRam
Your application has called the LoadMediaIntoRam function (described on LoadMediaIntoRam ). The Movie Toolbox calls the progress function that is assigned to the destination media.
progressOpImportMovie
Your application has called the ConvertFileToMovieFile function (described on ConvertFileToMovieFile ). The Movie Toolbox calls the progress function that is associated with the destination movie file. This flag is also used, as appropriate, for the PasteHandleIntoMovie functions (described on PasteHandleIntoMovie ).
progressOpExportMovie
Your application has called the ConvertMovieFile function (described on ConvertMovieToFile ). The Movie Toolbox calls the progress function that is associated with the destination movie. This flag is also used, as appropriate, for the PutMovieIntoTypedHandle function (described on PutMovieIntoTypedHandle ).
percentDone
Contains a fixed-point value indicating how far the operation has progressed. Its value is always between 0.0 and 1.0. This parameter is valid only when the message field is set to movieProgressUpdatePercent .
refcon
Reference constant value for use by your progress function. Your application specifies the value of this reference constant when you assign the progress function to the movie.

DESCRIPTION

Your progress function should return an error value. The Movie Toolbox examines this value after each movieProgressUpdatePercent message and before continuing the current operation. Set this value to a nonzero value, such as userCanceledErr , to cancel the operation; set it to noErr to continue.


© 1997 Apple Computer, Inc.

Previous | Chapter Top | Chapter Contents | Next